﻿#region License
/*
 * ArgumentParser - Parsing class for command line arguments
 * Copyright (C) 2003 Sébastien Lorion
 * 
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 * 
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 */

// http://www.codeproject.com/KB/recipes/argumentparser.aspx
// http://www.koders.com/csharp/fid0A5ED76069ACC45830FD56C7CB4BE2354F15F149.aspx?s=mdef%3Asearch
#endregion License

using System;
using System.Collections;
using System.Globalization;
using System.Reflection;
using System.Resources;

namespace WgpgCore.ArgumentParser
{
    /// <summary>
    /// Used by the <see cref="WgpgCore.ArgumentParser.ArgumentParser"/> class to automatically set the affected member according to the value of the related command line argument.
    /// </summary>
    [AttributeUsage(AttributeTargets.Field | AttributeTargets.Property)]
    public sealed class AutoSetMemberAttribute : Attribute
    {
        /// <summary>
        /// Supported <see cref="System.Reflection.BindingFlags"/>.
        /// </summary>
        public const BindingFlags SupportedBindingFlags = BindingFlags.DeclaredOnly
                                                        | BindingFlags.Instance
                                                        | BindingFlags.NonPublic
                                                        | BindingFlags.Public
                                                        | BindingFlags.Static
                                                        | BindingFlags.FlattenHierarchy;

        /// <summary>
        /// Supported <see cref="System.Reflection.MemberTypes"/>.
        /// </summary>
        public const MemberTypes SupportedMemberTypes = MemberTypes.Field | MemberTypes.Property;

        /// <summary>
        /// Creates a new instance of <see cref="WgpgCore.ArgumentParser.AutoSetMemberAttribute"/> class with no related command line argument aliases.
        /// </summary>
        public AutoSetMemberAttribute()
        {
            Aliases = new ArrayList();
            Description = null;
            SwitchMeansFalse = false;
            ID = null;
            ResID = null;
        }

        /// <summary>
        /// Creates a new insance of <see cref="WgpgCore.ArgumentParser.AutoSetMemberAttribute"/> class with one or more possible related command line argument aliases.
        /// </summary>
        /// <param name="aliases">One or more possible related command line argument aliases.</param>
        public AutoSetMemberAttribute(params String[] aliases)
        {
            Aliases = new ArrayList(aliases);
            Description = null;
            SwitchMeansFalse = false;
            ResID = null;
            ID = null;
        }

        /// <summary>
        /// Gets the possible related command line argument aliases.
        /// </summary>
        public ArrayList Aliases { get; private set; }

        /// <summary>
        /// Gets or sets the description of the command line argument.
        /// </summary>
        public String Description { get; set; }

        /// <summary>
        /// Indicates the meaning of a command line switch.
        /// </summary>
        public Boolean SwitchMeansFalse { get; set; }

        /// <summary>
        /// Gets or sets the ID of this instance.
        /// </summary>
        public Object ID { get; set; }

        /// <summary>
        /// Gets or sets the resource ID to be used for retrieving culture aware aliases.
        /// <seealso cref="WgpgCore.ArgumentParser.AutoSetMemberAttribute.Resources"/>
        /// <seealso cref="WgpgCore.ArgumentParser.AutoSetMemberAttribute.Culture"/>
        /// </summary>
        public String ResID { get; set; }

        /// <summary>
        /// Gets or sets the <see cref="System.Resources.ResourceManager"/> to be used for retrieving culture aware aliases.
        /// <seealso cref="WgpgCore.ArgumentParser.AutoSetMemberAttribute.Culture"/>
        /// <seealso cref="WgpgCore.ArgumentParser.AutoSetMemberAttribute.ResID"/>
        /// </summary>
        public static ResourceManager Resources { get; set; }

        /// <summary>
        /// Gets or sets the <see cref="System.Globalization.CultureInfo"/> to be used for retrieving culture aware aliases.
        /// <seealso cref="WgpgCore.ArgumentParser.AutoSetMemberAttribute.Resources"/>
        /// <seealso cref="WgpgCore.ArgumentParser.AutoSetMemberAttribute.ResID"/>
        /// </summary>
        public static CultureInfo Culture { get; set; }
    }
}
